package com.by.log;

import java.util.Map;

/**
 * RPC日志上下文
 * 用于在RPC调用中传递日志相关的上下文信息
 */
public class RpcLogContext {
    /**
     * 追踪ID
     */
    private String traceId;

    /**
     * 跨度ID
     */
    private String spanId;

    /**
     * 父跨度ID
     */
    private String parentSpanId;

    /**
     * 服务名称
     */
    private String serviceName;

    /**
     * 方法名称
     */
    private String methodName;

    /**
     * RPC请求ID
     */
    private String requestId;

    /**
     * 自定义属性
     */
    private Map<String, String> attributes;

    public String getTraceId() {
        return traceId;
    }

    public void setTraceId(String traceId) {
        this.traceId = traceId;
    }

    public String getSpanId() {
        return spanId;
    }

    public void setSpanId(String spanId) {
        this.spanId = spanId;
    }

    public String getParentSpanId() {
        return parentSpanId;
    }

    public void setParentSpanId(String parentSpanId) {
        this.parentSpanId = parentSpanId;
    }

    public String getServiceName() {
        return serviceName;
    }

    public void setServiceName(String serviceName) {
        this.serviceName = serviceName;
    }

    public String getMethodName() {
        return methodName;
    }

    public void setMethodName(String methodName) {
        this.methodName = methodName;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Map<String, String> getAttributes() {
        return attributes;
    }

    public void setAttributes(Map<String, String> attributes) {
        this.attributes = attributes;
    }

    public String getAttribute(String key) {
        return attributes != null ? attributes.get(key) : null;
    }

    public void setAttribute(String key, String value) {
        if (attributes != null) {
            attributes.put(key, value);
        }
    }
}